from flask import Blueprint, render_template
from model import HouseInfo

detail_page = Blueprint('detail_page', __name__)


@detail_page.route('/house/<int:hid>')       # 房源详细数据展示
def detail(hid):
    # 从数据库中查询房源id为hid的房源对象
    house = HouseInfo.query.get(hid)
    # 获取房源对象的配套设施信息，比如床-宽带-洗衣机-空调热水器-暖气
    facilities_str = house.facilities
    # 将分割后的每个设施名称保存在列表中
    facilities_list = facilities_str.split('-')
    return render_template('detail_page.html', house=house,
                           facilities=facilities_list)
